package cn.iocoder.yudao.module.handguard.dal.mysql.houserecord;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.handguard.dal.dataobject.houserecord.HouseRecordDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.handguard.controller.app.houserecord.vo.*;

/**
 * 用户-房子资产记录 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface HouseRecordMapper extends BaseMapperX<HouseRecordDO> {

    default PageResult<HouseRecordDO> selectPage(HouseRecordPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<HouseRecordDO>()
                .eqIfPresent(HouseRecordDO::getUserId, reqVO.getUserId())
                .eqIfPresent(HouseRecordDO::getArea, reqVO.getArea())
                .eqIfPresent(HouseRecordDO::getLandTypes, reqVO.getLandTypes())
                .eqIfPresent(HouseRecordDO::getBuildingStructure, reqVO.getBuildingStructure())
                .eqIfPresent(HouseRecordDO::getHouseType, reqVO.getHouseType())
                .eqIfPresent(HouseRecordDO::getAreaOfStructure, reqVO.getAreaOfStructure())
                .eqIfPresent(HouseRecordDO::getOneOrTwo, reqVO.getOneOrTwo())
                .betweenIfPresent(HouseRecordDO::getMortgageTime, reqVO.getMortgageTime())
                .eqIfPresent(HouseRecordDO::getLoanAmount, reqVO.getLoanAmount())
                .betweenIfPresent(HouseRecordDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(HouseRecordDO::getId));
    }

    default List<HouseRecordDO> selectList(HouseRecordExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<HouseRecordDO>()
                .eqIfPresent(HouseRecordDO::getUserId, reqVO.getUserId())
                .eqIfPresent(HouseRecordDO::getArea, reqVO.getArea())
                .eqIfPresent(HouseRecordDO::getLandTypes, reqVO.getLandTypes())
                .eqIfPresent(HouseRecordDO::getBuildingStructure, reqVO.getBuildingStructure())
                .eqIfPresent(HouseRecordDO::getHouseType, reqVO.getHouseType())
                .eqIfPresent(HouseRecordDO::getAreaOfStructure, reqVO.getAreaOfStructure())
                .eqIfPresent(HouseRecordDO::getOneOrTwo, reqVO.getOneOrTwo())
                .betweenIfPresent(HouseRecordDO::getMortgageTime, reqVO.getMortgageTime())
                .eqIfPresent(HouseRecordDO::getLoanAmount, reqVO.getLoanAmount())
                .betweenIfPresent(HouseRecordDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(HouseRecordDO::getId));
    }

}
